#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int f[N][N];
int n, V, M;
int main()
{
	cin >> n >> V >> M;
	int v, m, w;
	for (int i = 0; i < n; i++) {
		cin >> v >> m >> w;
		for (int j = V; j >= v; j--) {
			for (int k = M; k >= m; k--) {
				f[j][k] = max(f[j][k], f[j - v][k - m] + w);
			}
		}
	}
	cout << f[V][M] << endl;
	return 0;
}